﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ShareHelper
{
    /// <summary>
    /// 生成手机硬件信息
    /// </summary>
    public class Device
    {
        /// <summary>
        /// 手机品牌
        /// </summary>
        private static List<string> VendorList { get; set; }

        /// <summary>
        /// 手机品牌对应型号
        /// </summary>
        private static Dictionary<string, List<string>> ModelDic { get; set; }

        /// <summary>
        /// 安卓版本
        /// </summary>
        private static List<string> Osversions { get; set; }

        static Device()
        {
            VendorList = new List<string> { "Xiaomi", "huawei", "vivo", "oppo" };
            List<string> data;
            ModelDic = new Dictionary<string, List<string>>();
            data = new List<string> { "Xiaomi 10Pro", "Xiaomi CC9", "Xiaomi 9", "Xiaomi 6", "Xiaomi Play" };
            ModelDic["Xiaomi"] = data;
            data = new List<string> { "Mate30", "Mate30 Pro", "nova 6", "nova 5", "Mate 20Pro", "Mate 40", "P20 Pro" };
            ModelDic["huawei"] = data;
            data = new List<string> { "vivo Y3", "vivo Z6", "vivo X30", "vivo NEX 3", "vivo X23" };
            ModelDic["vivo"] = data;
            data = new List<string> { "OPPO Find X2", "OPPO A11", "OPPO Reno3", "OPPO A8", "OPPO Find X2 Pro" };
            ModelDic["oppo"] = data;
            Osversions = new List<string> { "9.0", "8.1", "7.1.2", "6.0.1", "5.1.1" };
        }

        /// <summary>
        ///需要生硬件配置的账号 里面有写算法 根据 账号 每次生成都是固定的集齐
        /// </summary>
        /// <param name="user"></param>
        public Device(string user)
        {
            Random ra = new Random(user.GetHashCode());
            StringBuilder str = new StringBuilder("8671650");
            while (15 > str.Length)
                str.Append(ra.Next(0, 9));
            Id = str.ToString();
            Vendor = VendorList[ra.Next(0, VendorList.Count - 1)];
            var data = ModelDic[Vendor];
            Model = data[ra.Next(0, data.Count - 1)];
            Osversion = Osversions[ra.Next(0, Osversions.Count - 1)];
        }

        /// <summary>
        /// Id
        /// </summary>
        public string Id { get; }

        /// <summary>
        /// 手机厂商
        /// </summary>
        public string Vendor { get; }

        /// <summary>
        /// 手机型号
        /// </summary>
        public string Model { get; }

        /// <summary>
        /// 手机版本
        /// </summary>
        public string Osversion { get; }
    }
}